package com.zhong.gang.app.ui.login;

import android.view.View;
import androidx.annotation.NonNull;
import com.zhong.gang.app.R;
import com.zhong.gang.app.databinding.ActivityMineBinding;
import com.zhong.gang.app.db.UserUtils;
import com.zhong.gang.applib.base.act.ActBase;


public class MineAct extends ActBase<ActivityMineBinding> {
    private LoginPresenter presenter;

    @Override
    public int LayoutRes() {
        return R.layout.activity_mine;
    }

    @NonNull
    @Override
    public String CreateTitle() {
        return "我的";
    }

    @Override
    public void initView() {
        bind.setAct(this);
        bind.steelMillNameLayout.setVisibility(View.VISIBLE);
        presenter = new LoginPresenter();
        bind.accountName.setText(UserUtils.getIntent(this).getUser().getPhone()+"");
        bind.name.setText(UserUtils.getIntent(this).getUser().getName());
        bind.number.setText(UserUtils.getIntent(this).getUser().getIdCard());
        int roleId = UserUtils.getIntent(this).getRoleId();
        switch (roleId){
            case 9:
                bind.steelMillNameLayout.setVisibility(View.VISIBLE);
                bind.steelMillName.setText(UserUtils.getIntent(this).getUser().getMaterialYardName());
                bind.steelMillTitle.setText("所属料场");
                break;
            case 5:
                bind.steelMillNameLayout.setVisibility(View.VISIBLE);
                bind.steelMillTitle.setText("所属钢厂");
                bind.steelMillName.setText(UserUtils.getIntent(this).getUser().getSteelMillName());
                break;
            default:
                bind.steelMillNameLayout.setVisibility(View.GONE);
                bind.steelMillTitle.setText("职位");
                bind.steelMillName.setText("管理员");
                break;
        }
    }

    public void onViewClicked(View view) {
        switch (view.getId()){
            case R.id.change_pass:
                openActivity(ChangePassAct.class);
                break;
            case R.id.login_out:
                presenter.loginOut(this);
                break;
        }
    }
}
